package gen

var (
	DefaultTableTemplate = `package {{.packageName}}
	{{$isHaveUUID := ""}}
// {{UnderScoreToCamel .tableName}} {{.tableDesc}}
type {{UnderScoreToCamel .tableName}} struct { {{range .fields}} {{if Contains .Desc "uuid"}} {{$isHaveUUID = UnderScoreToCamel .Name}} {{end}}
	{{UnderScoreToCamel .Name}} {{.Type}} ` + "`json:\"{{.Name}}\"`" + ` // {{.Desc}}{{end}}
}

func (c *{{UnderScoreToCamel .tableName}}) TableName() string {
	return "{{.tableName}}"
}
{{ if ne $isHaveUUID "" }}
func (c *{{UnderScoreToCamel .tableName}}) AfterCreate(tx *gorm.DB) error {
	if c.{{$isHaveUUID}} != "" {
		c.{{$isHaveUUID}} = uuid.New().String()
	}
	return nil
}
{{end}}
`
	DefaultFileNameTemplate = `{{.tableName}}_gen.go`
)
